aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/[username]/receive/+page.server.js
blob: 777c1dd7cf9a56682e11169ef346bb58d0187006 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import getRates from "$lib/rates";
import { redirect } from "@sveltejs/kit";

export const load = async ({ cookies, params: { username }, parent, url }) => {
	const token = cookies.get("token");
	const rates = await getRates();
	if (!token) redirect(307, `/pay/${username}`);
	const { subject, user } = await parent();
	const aid = cookies.get("aid");

	if (aid && user?.id !== aid) redirect(307, "/invoice");
	return {
		rate: rates[subject.currency],
		text: `${username}@${url.host}`,
	};
};